package com.labraff.redvideo;

import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class loading extends AppCompatActivity {


    private boolean firstOpen = true;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_loading);
        TextView txt = findViewById(R.id.cnt);
        CountDownTimer timer = new CountDownTimer(5000, 1000) {
            public void onTick(long millisUntilFinished) {
                txt.setText("加载:" + (millisUntilFinished / 1000 +1)  + "秒");
            }
            public void onFinish() {
                firstOpen = false;
                Intent intent = new Intent(loading.this, MainActivity.class);
                startActivity(intent);
            }
        };
        timer.start();
    }

    @Override
    protected void onStart() {
        super.onStart();
        if(!firstOpen){
            Intent intent = new Intent(loading.this, MainActivity.class);
            startActivity(intent);
            return;
        }
    }
}